/*
 * Toedo
 * Copyright (C) 2009-2010 J. Devauchelle and contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 3 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package org.toedo.model.comparators;

import java.util.Comparator;

import org.toedo.model.Tag;
import org.toedo.model.enums.SortDirection;

public class TagComparator implements Comparator<Tag> {

	private SortDirection mSortDirection;
	
	public TagComparator() {
		this(SortDirection.EnAscending);
	}
	
	public TagComparator(SortDirection sortDirection) {
		mSortDirection = sortDirection;
	}
	
	@Override
	public int compare(Tag arg0, Tag arg1) {
		switch (mSortDirection) {
		case EnAscending : return arg0.getName().compareToIgnoreCase(arg1.getName());
		case EnDescending : return arg1.getName().compareToIgnoreCase(arg0.getName());
		default : return arg0.getName().compareToIgnoreCase(arg1.getName());
		}
	}

}
